#!/usr/bin/php -c .
<?php
if(file_exists('exp.phar')){
	echo "\n     == exp\n\n     == Removing old build...";
	if(!unlink('exp.phar')){
		echo " failed.\n";
		exit(0);
	}
	echo "    done.";
}
echo "\n     == Creating phar archive...";
$phar = new Phar('exp.phar',0,'exp.phar');
echo " done.\n     == Building exp...";
$phar->buildFromIterator(
	new RecursiveIteratorIterator(
     new RecursiveDirectoryIterator('./')),
	'./');

$stub = '#!/usr/bin/php
<?php
	require_once "phar://".__FILE__."/exp.php";
 	__HALT_COMPILER();
?>';
echo "          done.\n     == Writing bootloader...";
$phar->setStub($stub);
echo "    done.\n     == Finishing build...";
// System('mv exp.phar exp');  // - currently breaks phar:// due to lack of file extension :(
System('chmod +x exp.phar');
echo "       done.\n\n";